package com.wl.dzt.basic.controller;

import com.wl.dzt.basic.service.BasicPowerService;
import com.wl.dzt.sys.util.CollectionUtil;
import com.wl.dzt.sys.util.WebUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * @author wl_code@163.com
 * @version 1.0
 * @date 2018/7/12/012
 * @description 权限控制器
 * 用于分配和初始化权限
 * 
 */
@ApiIgnore
@Controller
@RequestMapping("admin/basciPower")
public class BasicPowerController {

	/**
	 * 权限服务层
	 */
	@Resource
	private BasicPowerService basicPowerService;

	/**
	 * <b>获取角色</b>
	 * <p>
	 * 根据角色类型获取角色
	 * </p>
	 *
	 * @param response
	 */
	@PostMapping("listPowerDic")
	public void listPowerDic(HttpServletResponse response) {
		WebUtils.json(basicPowerService.listPowerDic(), response);
	}

	/**
	 * <b>获取角色的模块</b>
	 * <p>
	 * 根据角色编号获取所拥有的模块
	 * </p>
	 *
	 * @param response
	 * @param roleId
	 */
	@PostMapping("listRoleModel")
	public void listRoleModel(HttpServletResponse response, String roleId) {
		WebUtils.print(CollectionUtil.join(basicPowerService.getRoleModels(roleId), ","), response);
	}

}
